package org.example.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import sun.security.provider.MD5;

public class PasswordUtils {
    public static BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();

    public static boolean isMatch(String password, String DBPassword) {
        return bCryptPasswordEncoder.matches(password, DBPassword);
    }

    public static String MD5Encode(String password) {
        String MD5PassWord = bCryptPasswordEncoder.encode(password);
        return MD5PassWord;
    }

    public static void main(String[] args) {
        System.out.println(isleagl("1234a"));
    }
    public static boolean isleagl(String password){
        String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$";
        //密码必须包含数字和字母 且在6-18位之间
        return password.matches(regex);
    }
}
